<template>
  <div>
    <van-search v-model="value" placeholder="请输入" @cancel="goBack" />
    <div class="history-record">
      <p>历史记录</p>
      <van-tag v-for="(tag, index) in tags" :key="index" closable @click="searchTag(tag)">
        {{ tag }}
      </van-tag>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const value = ref('')
const tags = ref(['淡香水', '洗衣液', '清洗剂'])

const goBack = () => router.back()
const searchTag = (tag) => {
  value.value = tag
  console.log('搜索标签：', tag)
}
</script>

<style scoped>
.history-record {
  padding: 15px;
}
</style>